/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Customer;

import db.Jdbc;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;

/**
 *
 * @author sd
 */
public class CustomerDaoLmpl implements Customerdao{

    public Customer login( String ID, String password) {
         Connection conn = null;
	PreparedStatement pstat = null;
	ResultSet rs = null;
	String sql = "select * from user where Name=? ";
        try {
            conn = Jdbc.getConnection();
            pstat = conn.prepareStatement(sql);
            pstat.setString(1, ID);
            rs = pstat.executeQuery();
            if(rs.next()){
                String pwd=rs.getString("Password");
                System.out.println(pwd);
                if(pwd.equals(password)){
                    JOptionPane.showMessageDialog(null, "<html><font Color='red'>登陆成功！</font>", "信息提示", 3);

                }else{
                   JOptionPane.showMessageDialog(null, "<html><font Color='red'>登陆失败！</font>", "信息提示", 3);
 
                }
            }else{
                JOptionPane.showMessageDialog(null, "<html><font Color='red'>没有此用户！</font>", "信息提示", 3);
 
            }
            
            //rs.
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
	
        return null;
    }

    @Override
    public Customer login(int ID, String password) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    
}

